@import '../../styles/common';
@import '../../Loader/styles/mixin';
@import 'mixin';

//
// Table
// --------------------------------------------------

// Table Content
.rs-table {
  position: relative;
  overflow: hidden;

  &-column-resizing {
    cursor: ew-resize;
    user-select: none;
  }

  &-row {
    overflow: hidden;
    position: absolute;
    height: 36px;
    width: 100%;
    top: 0;

    &.virtualized {
      .pointer-event-none();
    }
  }

  &-row-expanded {
    position: absolute;
    height: 46px;
    bottom: 0;
    width: 100%;
    z-index: 4;
    border-top: 1px solid var(--rs-border-secondary);
    padding: 10px;
    background-color: var(--rs-bg-card);
  }

  &-hover &-row:hover &-cell-group {
    background-color: var(--rs-bg-card);
  }

  &-hover &-row:hover &-cell {
    background-color: var(--rs-bg-card);
  }

  &-row-header {
    background-color: var(--rs-bg-card);
  }

  &-row-header &-cell {
    background-color: var(--rs-bg-card);
  }

  &-row-header &-cell-group-shadow {
    z-index: @zindex-table-row-cell-group-shadow;
    box-shadow: none;
  }

  &-hover &-row:not(&-row-header):hover,
  &-hover &-row:hover &-cell-group,
  &-hover &-row:hover &-cell {
    background-color: var(--rs-state-hover-bg);
  }

  &-hover &-row-header:hover &-cell-group,
  &-hover &-row-header:hover &-cell {
    background-color: var(--rs-bg-card);
  }

  // The thead
  &-header-row-wrapper {
    z-index: @zindex-table-header-row-wrapper;
    position: relative;
    font-size: 12px;
    color: var(--rs-text-secondary);
  }

  &-affix-header {
    z-index: @zindex-table-header-row-wrapper+1;
    visibility: hidden;

    &.fixed {
      visibility: visible;
    }
  }

  &-body-row-wrapper {
    position: relative;
    overflow: hidden;
    z-index: @zindex-table-body-row-wrapper;
  }

  &-body-info {
    width: 100%;
    text-align: center;
    top: 50%;
    position: absolute;
    margin-top: -20px;
    line-height: 40px;

    .icon {
      margin: 0 10px;
    }

    &-wheel-area {
      width: 100%;
    }
  }

  &-body-wheel-area {
    width: 100%;
  }

  &-loader-wrapper {
    position: absolute;
    height: 100%;
    width: 100%;
    background-color: var(--rs-loader-backdrop);
    opacity: 0;
    transition: opacity 0.2s ease-in;
    .pointer-event-none();
  }

  &-loader {
    width: 100%;
    text-align: center;
    top: 50%;
    position: absolute;
    margin-top: -20px;
    line-height: 40px;

    &-icon {
      .set-side-length(@loader-default-diameter);
      .loader-spin();

      display: inline-block;
      position: relative;
      margin-right: @loader-content-spin-spacing-horizontal;
      // Make sure loader vertical-align center
      padding-top: 3px;
    }
  }

  &-loading &-loader-wrapper {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    // When loading cover scrollbar.
    z-index: 1;
  }

  &-cell {
    height: 36px;
    display: block;
    overflow: hidden;
    position: absolute;
    white-space: normal;
    background-color: var(--rs-bg-card);
    border-bottom: 1px solid var(--rs-border-secondary);

    &.first {
      border-left-width: 0;
    }

    &-wrap1 {
      display: table;
    }

    &-wrap2 {
      display: table-row;
    }

    &-wrap3 {
      display: table-cell;
      vertical-align: middle;
    }

    &-content {
      padding: @table-cell-padding-y @table-cell-padding-x;
      .ellipsis();
    }

    &-header &-content {
      padding: @table-header-padding-y @table-header-padding-x;
      line-height: @table-header-line-height;
    }

    &-header {
      &-sort-wrapper {
        cursor: pointer;
        margin-left: @table-header-sort-wrapper-margin-left;
        display: inline-block;
      }

      &-icon-sort {
        color: var(--rs-table-sort);
        font-size: 16px;
        line-height: @table-header-line-height;
      }
    }

    &-rowspan {
      border-bottom: 1px solid var(--rs-border-secondary) !important;
    }
  }

  &-cell-full-text {
    &:hover {
      z-index: 1 !important;
      width: auto !important;
      box-shadow: inset @table-cell-hover-color 0px 0px 2px;

      .rs-table-cell-content {
        width: auto !important;
      }
    }
  }

  &-cell-header-sortable &-cell-content {
    cursor: pointer;
  }

  &-column-resize-spanner {
    .column-resize-spanner();

    box-sizing: content-box;

    &::after,
    &::before {
      content: ' ';
      position: absolute;
      width: 0;
      height: 0;
      margin: auto;
      bottom: 0;
      top: 0;
      display: none;
    }

    &::before {
      border-style: dashed solid dashed dashed;
      border-color: transparent var(--rs-table-resize) transparent transparent;
      border-width: @table-column-resize-spanner-triangle-side-length;
      right: 4px;
    }

    &::after {
      border-style: dashed dashed dashed solid;
      border-color: transparent transparent transparent var(--rs-table-resize);
      border-width: @table-column-resize-spanner-triangle-side-length;
      left: 4px;
    }
  }

  // Table not resizing , header should show resize-spanner .
  &:not(&-column-resizing) &-cell-header &-cell:hover ~ &-column-resize-spanner,
  &:not(&-column-resizing) &-column-resize-spanner:hover {
    background-color: var(--rs-table-resize);

    &::before,
    &::after {
      display: block;
    }
  }

  &-cell-group {
    &-fixed-right,
    &-fixed-left {
      position: absolute;
      z-index: @zindex-table-cell-group-fixed;
      background-color: var(--rs-bg-card);
    }

    &-shadow,
    &-left-shadow {
      box-shadow: 3px 0 5px var(--rs-table-shadow) /* rtl:ignore */;
    }

    &-right-shadow {
      box-shadow: -3px 0 5px var(--rs-table-shadow) /* rtl:ignore */;
    }
  }

  &-mouse-area {
    display: none;
    background-color: var(--rs-table-resize);
    left: -1px;
    top: 0;
    position: absolute;
    width: 1px;
    z-index: @zindex-table-mouse-area;

    > span {
      .column-resize-spanner();

      background-color: var(--rs-table-resize);
      position: absolute;
      left: (-1 * (@table-column-resize-spanner-width / 2));
    }
  }

  &-word-wrap &-cell-content {
    white-space: normal;
  }

  &-bordered {
    border: 1px solid var(--rs-border-secondary);
  }

  &-cell-bordered &-cell {
    border-right: 1px solid var(--rs-border-secondary);
  }

  &-column-group {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    width: 100%;

    &-header {
      border-bottom: 1px solid var(--rs-border-secondary);
      position: absolute;
      width: 100%;

      &-content {
        display: table-cell;
        padding: 10px;
      }
    }

    &-cell {
      position: absolute;
      border-right: 1px solid var(--rs-border-secondary);
    }
  }
}

// Tree Table

.rs-table-cell-expand-wrapper {
  margin-right: 10px;
  display: inline-block;
  cursor: pointer;
}

.rs-table-cell-expand-icon {
  cursor: pointer;
  outline: none;
  font-size: 16px;
}

// Scrollbar
.rs-table-scrollbar {
  background-color: var(--rs-table-scrollbar-track);
  position: absolute;
  transition: background @table-scrollbar-timing-duration linear,
    transform @table-scrollbar-timing-duration linear;
  opacity: 0.6;
  // Make sure Scrollbar on the loader.
  z-index: 1;

  &-hide {
    display: none;
  }

  &-handle {
    position: absolute;
    background-color: var(--rs-table-scrollbar-thumb);
    border-radius: 4px;
  }

  &-pressed {
    z-index: 1;
  }

  &-pressed &-handle {
    background-color: var(--rs-table-scrollbar-thumb-active);
  }

  &-horizontal {
    width: 100%;
    height: @table-scrollbar-width;
    bottom: 0;

    &.fixed {
      position: fixed;
    }
  }

  &-horizontal &-handle {
    height: @table-scrollbar-handle-width;
    left: 0 /* rtl:ignore */;
    top: @table-scrollbar-handle-gap;
  }

  &-pressed&-horizontal:hover,
  &-horizontal:hover {
    transform-origin: center bottom;
    transform: scaleY(1.3);
  }

  &-vertical {
    top: 0;
    right: 0;
    width: @table-scrollbar-width;
    // Reserve scroll bar position.
    bottom: @table-scrollbar-width;
    background-color: var(--rs-table-scrollbar-vertical-track);
  }

  &-vertical &-handle {
    min-height: 20px;
    width: @table-scrollbar-handle-width;
    top: 0;
    left: @table-scrollbar-handle-gap;
  }

  &-pressed&-vertical:hover,
  &-vertical:hover {
    transform-origin: right center;
    transform: scaleX(1.3);
  }
}
